package com.lbd.email.conttoller;

import com.lbd.base.controller.BaseController;
import com.lbd.commons.Result;
import com.lbd.commons.ResultState;
import com.lbd.email.bean.EmailLog;
import com.lbd.email.conttoller.vo.EmailLogVo;
import com.lbd.email.service.EmailLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by wang on 2016/10/11.
 */
@RestController
@RequestMapping("/emailLog")
public class EmailLogController extends BaseController {

    @Autowired
    EmailLogService emailService;

    /**
     * 保存邮件模板信息
     *
     * @param emailLog
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result add(EmailLog emailLog) {
        emailService.save(emailLog);
        return new Result(ResultState.SUCCESS, "成功！");

    }

    /**
     * 分页查询邮件模板信息
     *
     * @param page       第几页
     * @param rows       一页多少条
     * @param emailLogVo 查询条件
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result list(int page, int rows, EmailLogVo emailLogVo) {
        return new Result(ResultState.SUCCESS, "查询成功", emailService.findByPageConditionJpql(page, rows, emailLogVo));

    }
}
